//
//  YDSendBrokerInformationController.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2018/1/30.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDSendBrokerInformationController.h"

@interface YDSendBrokerInformationController ()<UITextFieldDelegate>
//姓名
@property (nonatomic , weak) UIView *nameLine;
@property (nonatomic , weak) UILabel *nameLabel;
@property (nonatomic , weak) UITextField *nameTextField;
//身份证
@property (nonatomic , weak) UIView *cardLine;
@property (nonatomic , weak) UILabel *cardLabel;
@property (nonatomic , weak) UITextField *cardTextField;
//银行卡
@property (nonatomic , weak) UIView *bankLine;
@property (nonatomic , weak) UILabel *bankLabel;
@property (nonatomic , weak) UITextField *bankTextField;
//手机号
@property (nonatomic , weak) UIView *phoneLine;
@property (nonatomic , weak) UILabel *phoneLabel;
@property (nonatomic , weak) SYPhoneTextField *phoneTextField;
//注释
@property (nonatomic , weak) UILabel *markLabel;

//提交按钮
@property (nonatomic , weak) SYNoHeightedButton *sendButton;
//


@end

@implementation YDSendBrokerInformationController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"填写身份信息";
    [self addChildViews];
}

-(void)addChildViews
{
    [self nameLine];
    [self nameLabel];
    [self nameTextField];
    
    [self cardLine];
    [self cardLabel];
    [self cardTextField];
    
    [self bankLine];
    [self bankLabel];
    [self bankTextField];
    
    [self phoneLine];
    [self phoneLabel];
    [self phoneTextField];
    
    
    [self markLabel];
    [self sendButton];
}






///////////////***********//////////////////
///**********姓名********///
-(UIView *)nameLine
{
    if (_nameLine == nil) {
        UIView *nameLine = [[UIView alloc] init];
        [self.view addSubview:nameLine];
        nameLine.backgroundColor = [UIColor colorWithHexString:mainGray];
        [nameLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(rate375(325)));
            make.centerX.equalTo(self.view);
            make.height.equalTo(@1);
            if (isPhoneX) {
                make.top.equalTo(self.view).offset(rateX812(60));
            }else{
                make.top.equalTo(self.view).offset(rate750(50));
            }
        }];
        
        _nameLine = nameLine;
    }
    return _nameLine;
}
///**********身份证下划线********///
-(UIView *)cardLine
{
    if (_cardLine == nil) {
        UIView *cardLine = [[UIView alloc] init];
        [self.view addSubview:cardLine];
        cardLine.backgroundColor = [UIColor colorWithHexString:mainGray];
        [cardLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(rate375(325)));
            make.centerX.equalTo(self.view);
            make.height.equalTo(@1);
            if (isPhoneX) {
                make.top.equalTo(self.nameLine.mas_bottom).offset(rateX812(50));
            }else{
                make.top.equalTo(self.nameLine.mas_bottom).offset(rate750(50));
            }
        }];
        
        _cardLine = cardLine;
    }
    return _cardLine;
}
///**********银行卡下划线********///
-(UIView *)bankLine
{
    if (_bankLine == nil) {
        UIView *bankLine = [[UIView alloc] init];
        [self.view addSubview:bankLine];
        bankLine.backgroundColor = [UIColor colorWithHexString:mainGray];
        [bankLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(rate375(325)));
            make.centerX.equalTo(self.view);
            make.height.equalTo(@1);
            if (isPhoneX) {
                make.top.equalTo(self.cardLine.mas_bottom).offset(rateX812(50));
            }else{
                make.top.equalTo(self.cardLine.mas_bottom).offset(rate750(50));
            }
        }];
        
        _bankLine = bankLine;
    }
    return _bankLine;
}
///**********手机号下划线********///
-(UIView *)phoneLine
{
    if (_phoneLine == nil) {
        UIView *phoneLine = [[UIView alloc] init];
        [self.view addSubview:phoneLine];
        phoneLine.backgroundColor = [UIColor colorWithHexString:mainGray];
        [phoneLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(rate375(325)));
            make.centerX.equalTo(self.view);
            make.height.equalTo(@1);
            if (isPhoneX) {
                make.top.equalTo(self.bankLine.mas_bottom).offset(rateX812(50));
            }else{
                make.top.equalTo(self.bankLine.mas_bottom).offset(rate750(50));
            }
        }];
        
        _phoneLine = phoneLine;
    }
    return _phoneLine;
}

//姓名
-(UILabel *)nameLabel
{
    if (_nameLabel == nil) {
        UILabel *nameLabel = [[UILabel alloc] init];
        [self.view addSubview:nameLabel];
        nameLabel.textColor = [UIColor colorWithHexString:battleshipGrey];
        nameLabel.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        nameLabel.textAlignment = NSTextAlignmentLeft;
        nameLabel.text = @"姓名";
        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.nameLine);
            if (isPhoneX) {
                make.bottom.equalTo(self.nameLine.mas_top).offset(-rateX812(15));
            }else{
                make.bottom.equalTo(self.nameLine.mas_top).offset(-rate750(15));
            }
        }];
        _nameLabel = nameLabel;
    }
    return _nameLabel;
}
//姓名输入框
-(UITextField *)nameTextField
{
    if (_nameTextField == nil) {
        UITextField *nameTextField = [[UITextField alloc] init];
        [self.view addSubview:nameTextField];
        nameTextField.textColor = [UIColor blackColor];
        nameTextField.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        nameTextField.placeholder = @"请输入姓名";
        nameTextField.backgroundColor = [UIColor clearColor];
        nameTextField.borderStyle = UITextBorderStyleNone;
        nameTextField.textAlignment = NSTextAlignmentLeft;
        nameTextField.keyboardType = UIKeyboardTypeDefault;
        nameTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
        nameTextField.keyboardAppearance=UIKeyboardAppearanceDefault;
        nameTextField.returnKeyType =UIReturnKeyDone;
        [nameTextField setClearButtonMode:UITextFieldViewModeWhileEditing];
        [nameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.nameLabel);
            make.left.equalTo(self.nameLabel.mas_right).offset(rate375(20+ 14));
            make.right.equalTo(self.nameLine);
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(20)));
            }else{
                make.height.equalTo(@(rate750(20)));
            }
        }];
        nameTextField.tintColor = [UIColor blackColor];
        nameTextField.delegate = self;
        
        //        [nameTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
        
        _nameTextField = nameTextField;
    }
    return _nameTextField;
}

//身份证
-(UILabel *)cardLabel
{
    if (_cardLabel == nil) {
        UILabel *cardLabel = [[UILabel alloc] init];
        [self.view addSubview:cardLabel];
        cardLabel.textColor = [UIColor colorWithHexString:battleshipGrey];
        cardLabel.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        cardLabel.textAlignment = NSTextAlignmentLeft;
        cardLabel.text = @"身份证";
        [cardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.cardLine);
            if (isPhoneX) {
                make.bottom.equalTo(self.cardLine.mas_top).offset(-rateX812(15));
            }else{
                make.bottom.equalTo(self.cardLine.mas_top).offset(-rate750(15));
            }
        }];
        _cardLabel = cardLabel;
    }
    return _cardLabel;
}

-(UITextField *)cardTextField
{
    if (_cardTextField == nil) {
        UITextField *cardTextField = [[UITextField alloc] init];
        [self.view addSubview:cardTextField];
        cardTextField.textColor = [UIColor blackColor];
        cardTextField.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        cardTextField.placeholder = @"请输入正确的身份证号";
        cardTextField.backgroundColor = [UIColor clearColor];
        cardTextField.borderStyle = UITextBorderStyleNone;
        cardTextField.textAlignment = NSTextAlignmentLeft;
        cardTextField.keyboardType = UIKeyboardTypeDefault;
        cardTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
        cardTextField.keyboardAppearance=UIKeyboardAppearanceDefault;
        cardTextField.returnKeyType =UIReturnKeyDone;
        [cardTextField setClearButtonMode:UITextFieldViewModeWhileEditing];
        [cardTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.cardLabel);
            make.left.equalTo(self.cardLabel.mas_right).offset(rate375(20));
            make.right.equalTo(self.cardLine);
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(20)));
            }else{
                make.height.equalTo(@(rate750(20)));
            }
        }];
        cardTextField.tintColor = [UIColor blackColor];
        cardTextField.delegate = self;
        
        //        [idCradTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
        
        _cardTextField = cardTextField;
    }
    return _cardTextField;
}


//银行卡
-(UILabel *)bankLabel
{
    if (_bankLabel == nil) {
        UILabel *bankLabel = [[UILabel alloc] init];
        [self.view addSubview:bankLabel];
        bankLabel.textColor = [UIColor colorWithHexString:battleshipGrey];
        bankLabel.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        bankLabel.textAlignment = NSTextAlignmentLeft;
        bankLabel.text = @"银行卡";
        [bankLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bankLine);
            if (isPhoneX) {
                make.bottom.equalTo(self.bankLine.mas_top).offset(-rateX812(15));
            }else{
                make.bottom.equalTo(self.bankLine.mas_top).offset(-rate750(15));
            }
        }];
        _bankLabel = bankLabel;
    }
    return _bankLabel;
}

-(UITextField *)bankTextField
{
    if (_bankTextField == nil) {
        UITextField *bankTextField = [[UITextField alloc] init];
        [self.view addSubview:bankTextField];
        bankTextField.textColor = [UIColor blackColor];
        bankTextField.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        bankTextField.placeholder = @"请输入正确的银行卡号";
        bankTextField.backgroundColor = [UIColor clearColor];
        bankTextField.borderStyle = UITextBorderStyleNone;
        bankTextField.textAlignment = NSTextAlignmentLeft;
        bankTextField.keyboardType = UIKeyboardTypeNumberPad;
        bankTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
        bankTextField.keyboardAppearance=UIKeyboardAppearanceDefault;
        bankTextField.returnKeyType =UIReturnKeyDone;
        [bankTextField setClearButtonMode:UITextFieldViewModeWhileEditing];
        [bankTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.bankLabel);
            make.left.equalTo(self.bankLabel.mas_right).offset(rate375(20));
            make.right.equalTo(self.bankLine);
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(20)));
            }else{
                make.height.equalTo(@(rate750(20)));
            }
        }];
        bankTextField.tintColor = [UIColor blackColor];
        bankTextField.delegate = self;
        
        //        [bankTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
        
        _bankTextField = bankTextField;
    }
    return _bankTextField;
}

//手机号
-(UILabel *)phoneLabel
{
    if (_phoneLabel == nil) {
        UILabel *phoneLabel = [[UILabel alloc] init];
        [self.view addSubview:phoneLabel];
        phoneLabel.textColor = [UIColor colorWithHexString:battleshipGrey];
        phoneLabel.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        phoneLabel.textAlignment = NSTextAlignmentLeft;
        phoneLabel.text = @"手机号";
        [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.phoneLine);
            if (isPhoneX) {
                make.bottom.equalTo(self.phoneLine.mas_top).offset(-rateX812(15));
            }else{
                make.bottom.equalTo(self.phoneLine.mas_top).offset(-rate750(15));
            }
        }];
        _phoneLabel = phoneLabel;
    }
    return _phoneLabel;
}
-(SYPhoneTextField *)phoneTextField
{
    if (_phoneTextField == nil) {
        SYPhoneTextField *phoneTextField = [[SYPhoneTextField alloc] init];
        [self.view addSubview:phoneTextField];
        phoneTextField.textColor = [UIColor blackColor];
        phoneTextField.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        phoneTextField.placeholder = @"请输入手机号码";
        phoneTextField.backgroundColor = [UIColor clearColor];
        phoneTextField.borderStyle = UITextBorderStyleNone;
        phoneTextField.textAlignment = NSTextAlignmentLeft;
        phoneTextField.keyboardType = UIKeyboardTypeNumberPad;
        phoneTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
        phoneTextField.keyboardAppearance=UIKeyboardAppearanceDefault;
        phoneTextField.returnKeyType =UIReturnKeyDone;
        [phoneTextField setClearButtonMode:UITextFieldViewModeWhileEditing];
        [phoneTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.phoneLabel);
            make.left.equalTo(self.phoneLabel.mas_right).offset(rate375(20));
            make.right.equalTo(self.phoneLine);
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(20)));
            }else{
                make.height.equalTo(@(rate750(20)));
            }
        }];
        phoneTextField.tintColor = [UIColor blackColor];
        phoneTextField.delegate = self;
        
        //        [phoneTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
        
        _phoneTextField = phoneTextField;
    }
    return _phoneTextField;
}

//提示文字
-(UILabel *)markLabel
{
    if (_markLabel == nil) {
        UILabel *markLabel = [[UILabel alloc] init];
        [self.view addSubview:markLabel];
        markLabel.textColor = [UIColor colorWithHexString:battleshipGrey];
        markLabel.text = @"注：请填写与持卡人一致的身份信息";
        markLabel.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        markLabel.textAlignment = NSTextAlignmentLeft;
        [markLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.phoneLine);
            if (isPhoneX) {
                make.top.equalTo(self.phoneLine.mas_bottom).offset(rateX812(20));
            }else{
                make.top.equalTo(self.phoneLine.mas_bottom).offset(rate750(20));
            }
        }];
        _markLabel = markLabel;
    }
    return _markLabel;
}

-(SYNoHeightedButton *)sendButton
{
    if (_sendButton == nil) {
        SYNoHeightedButton *sendButton = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
        [self.view addSubview:sendButton];
        [sendButton setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:Orange alpha:0.3]] forState:UIControlStateDisabled];
        [sendButton setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:Orange]] forState:UIControlStateNormal];
        [sendButton setTitle:@"提交申请" forState:UIControlStateNormal];
        [sendButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [sendButton setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
        sendButton.titleLabel.font = [UIFont systemFontOfSize:font16ScreenWRate * LKScreenW];
        sendButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        
        [sendButton mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.width.equalTo(@(rate375(284)));
            make.centerX.equalTo(self.view);
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(48)));
                make.top.equalTo(self.markLabel.mas_bottom).offset(rateX812(20));
            }else{
                make.height.equalTo(@(rate750(48)));
                make.top.equalTo(self.markLabel.mas_bottom).offset(rate750(20));
            }
            
        }];
        sendButton.enabled = NO;
        [sendButton addTarget:self action:@selector(sureButtonClick:) forControlEvents:UIControlEventTouchDown];
        sendButton.layer.cornerRadius = 5.0f;
        sendButton.layer.masksToBounds = YES;
        
        _sendButton = sendButton;
    }
    return _sendButton;
}

-(void)sureButtonClick:(SYNoHeightedButton *)button
{
    DDLog(@"去赚钱吧")
}









@end
